<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
  <title><spring:message code="sys.dict.title" /></title>
  <meta name="decorator" content="grid-select"/>
</head>
<body title="<spring:message code="sys.dict.title" />">
<grid:grid id="groupGridId" url="${adminPath}/sys/dict/ajaxList?gid=${group.id}">
	<grid:column label="sys.common.key" hidden="true" name="id" width="100"/>
	<grid:column label="sys.common.opt" name="opt" formatter="button" width="100" sortable="false"/>
	<grid:button  groupname="opt" function="delete" />
    <grid:column label="sys.dict.label" name="label" query="true"  />
    <grid:column label="sys.dict.value" name="value" query="true"  />
	<grid:column label="sys.dict.remarks" name="remarks" query="true"  />
	<grid:column label="sys.dict.sort" name="sort" query="true"  />
	<grid:column label="sys.dict.group.delFlag"  name="delFlag" dict="sf" query="true" queryMode="select" />
    
	<grid:toolbar function="create" url="${adminPath}/sys/dict/create?gid=${group.id}"  />
	<grid:toolbar function="update" />
	<grid:toolbar function="delete" />
	<grid:toolbar title="启用" icon="fa-file-text-o" onclick="updateState('0')"/>
	<grid:toolbar title="停用" icon="fa-file-text-o" btnclass="btn-warning" onclick="updateState('1')"/>
	<grid:toolbar function="search" />
	<grid:toolbar function="reset" />
</grid:grid>

<script>
	function updateState(state) {
		var selectedRows = $("#groupGridIdGrid").jqGrid('getGridParam','selarrrow');
		var ids = [];
		// 如果没有选择，提示
		if (selectedRows.length == 0) {
			top.layer.alert('请至少选择一条数据!', {icon: 0, title:'警告'});
			return;
		}
		// 获取装车单号
		for (var i = 0; i < selectedRows.length; i++) {
			ids.push($("#groupGridIdGrid").jqGrid('getRowData', selectedRows[i]).id);
		}

		// POST请求发车确认
		$.ajax({
			type: "POST",
			url: "${adminPath}/sys/dict/updateState",
			data: {
				ids : ids,
				state : state
			},
			traditional: true,
			success: function (data) {
				if (data.ret == 0) {
					top.layer.alert(data.msg, {icon: 0, title:'提示'});
					//刷新表单
					refreshTable("groupGridIdGrid");
				}
				else {
					top.layer.alert(data.msg, {icon: 0, title:'提示'});
				}
			}
		});
	}
</script>
</body>
</html>